package com.hx.mq;

import com.hx.dto.MoodDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.jms.Destination;

/**
 * 消息生产者
 */
@Component
@Slf4j
public class MoodProducer {

    @Resource
    private JmsTemplate jmsTemplate;

    /**
     * destination 目标队列/主题 queue:队列  Topic:主题
     * moodDTO 前端实体类 message
     * @param destination
     * @param moodDTO
     */
    public void sendMessage(Destination destination, MoodDTO moodDTO){
        log.info("生产者---》》》用户id:{},说说id:{},进行点赞行为.",moodDTO.getUserId(),moodDTO.getId());
        System.out.println("生产者-------------------------->>>");
        jmsTemplate.convertAndSend(destination,moodDTO);
    }
}
